/**
 * =============================================================================
 * ************   Radio 单选框   ************
 * =============================================================================
 */
.mdui-radio-group {
  display: flex;
  flex-wrap: wrap;
  width: fit-content;

  &.mdui-group-vertical {
    flex-direction: column;
  }
}

.mdui-radio {
  position: relative;
  display: inline-block;
  height: 36px;
  margin: 0 16px;
  padding-left: 24px;
  line-height: 36px;
  cursor: pointer;
  user-select: none;

  // 隐藏系统 input 标签，用自定义的图标代替
  input {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    opacity: 0;
  }
}

/* 图标外圈 */
.mdui-radio-icon {
  position: absolute;
  top: 50%;
  left: 0;
  display: inline-block;
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  vertical-align: middle;
  border: 2px solid @color-black-icon;
  border-radius: 18px;
  transform: translateY(-50%);
  transition: all .3s @animation-curve-default,
    box-shadow .14s @animation-curve-default;

  // 图标内部圆圈
  &::before {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: @color-default-a200;
    border-radius: 50%;
    transform: scale(0);
    opacity: 0;
    transition: all .3s @animation-curve-default;
    content: ' ';
  }
}

/* 选中状态的图标 */
.mdui-radio input[type="radio"]:checked+.mdui-radio-icon {
  border-color: @color-default-a200;

  &::before {
    transform: scale(0.68);
    opacity: 1;
  }
}

/* 禁用状态的图标 */
.mdui-radio input[type="radio"]:disabled+.mdui-radio-icon {
  border-color: @color-black-icon-disabled !important;
}

/* 禁用且选中状态的图标 */
.mdui-radio input[type="radio"]:disabled:checked+.mdui-radio-icon {
  &::before {
    background-color: @color-black-icon-disabled !important;
  }
}

/* 未禁用时的阴影 */
.mdui-radio input[type="radio"]:not(:disabled) {

  &:hover,
  &:focus {
    &+.mdui-radio-icon {
      box-shadow: 0 0 0 15px rgba(0, 0, 0, 0.1);
    }

    /* 已选中时鼠标悬浮的阴影 */
    &:checked+.mdui-radio-icon {
      box-shadow: 0 0 0 15px rgba(red(@color-default-a200), green(@color-default-a200), blue(@color-default-a200), 0.16);
    }
  }
}

/* 禁用时 按下的阴影 */
.mdui-radio:active input[type="radio"]:disabled {
  &+.mdui-radio-icon {
    box-shadow: 0 0 0 15px rgba(0, 0, 0, 0.1);
  }
}

/**
 * =============================================================================
 * ************   Radio 强调色   ************
 * =============================================================================
 */

& {
  .loop-accent-theme(@counter-color) when (@counter-color > 0) {
    .loop-accent-theme((@counter-color - 1));
    @colorName: extract(@globalAccentColors, @counter-color);

    @color: 'color-@{colorName}-a200';

    .mdui-theme-accent-@{colorName} when not (@colorName =null) {

      // 选中状态的图标
      .mdui-radio input[type="radio"]:checked+.mdui-radio-icon {
        border-color: @@color;

        &::before {
          background-color: @@color;
        }
      }

      // 已选中时鼠标悬浮的阴影
      .mdui-radio input[type="radio"]:not(:disabled):checked {

        &:hover,
        &:focus {
          &+.mdui-radio-icon {
            box-shadow: 0 0 0 15px rgba(red(@@color), green(@@color), blue(@@color), 0.16);
          }
        }
      }
    }
  }

  .loop-accent-theme(length(@globalAccentColors));
}


/**
 * =============================================================================
 * ************   Radio dark   ************
 * =============================================================================
 */
.layout-theme({

  // 图标外圈
  .mdui-radio-icon {
    border-color: rgba(255, 255, 255, 0.7);
  }

  // 禁用状态
  .mdui-radio input[type="radio"]:disabled + .mdui-radio-icon {
    border-color: @color-white-icon-disabled !important;
  }

  // 禁用且选中状态
  .mdui-radio input[type="radio"]:disabled:checked + .mdui-radio-icon {
    &::before {
      background-color: @color-white-icon-disabled !important;
    }
  }

  // 未禁用时的阴影
  .mdui-radio input[type="radio"]:not(:disabled) {

    &:hover,
    &:focus {
      &+.mdui-radio-icon {
        box-shadow: 0 0 0 15px rgba(255, 255, 255, 0.1);
      }
    }
  }

  // 禁用时 按下的阴影
  .mdui-radio:active input[type="radio"]:disabled {
    & + .mdui-radio-icon {
      box-shadow: 0 0 0 15px rgba(255, 255, 255, 0.1);
    }
  }
});